package com.lyy.controller;

import com.lyy.entity.Param.PigInsertParam;
import com.lyy.entity.Param.PigUpdateParam;
import com.lyy.result.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.websocket.server.PathParam;

/**
 * @author Liangyaoyun
 */
@Tag(name = "猪的控制器",description = "对猪的增删改查")
@RestController
@RequestMapping("/api/v1/pig")
public class PigController {

    @PostMapping("/insert")
    @Operation(summary = "添加一只猪",description = "添加一只猪的名字")
    public Result insert(@RequestBody PigInsertParam pigInsertParam) {
        return Result.success("添加成功:" + pigInsertParam);
    }

    @GetMapping("/selectByPigId/{pigId}")
    @Operation(summary = "查询一只猪",description = "查询一只猪的详细信息")
    public Result selectByPigId(
            @Parameter(description = "按猪的主键查询猪的详细信息",required = true,example = "1")
            @PathVariable Integer pigId) {
        return Result.success("查询成功: " + pigId);
    }

    @PostMapping("/updateByPigId")
    @Operation(summary = "修改一只猪",description = "修改一只猪的名字")
    public Result updateByPigId(@RequestBody PigUpdateParam pigUpdateParam) {
        return Result.success("修改成功: " + pigUpdateParam);
    }

    @PostMapping("/deleteByPigId/{pigId}")
    @Operation(summary = "删除一只猪",description = "删除一只猪的信息")
    public Result deleteByPigId(@PathVariable Integer pigId) {
        return Result.success("删除成功: " + pigId);
    }

}
